package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.ClientTarkingList;
import cn.wolfcode.crm.mapper.ClientTarkingListMapper;
import cn.wolfcode.crm.query.ClientTarkingListQuery;
import cn.wolfcode.crm.service.IClientTarkingListService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class ClientTarkingListServiceImpl implements IClientTarkingListService {
    @Autowired
    private ClientTarkingListMapper clientTarkingListMapper;




    public void saveOrUpdate(ClientTarkingList entity) {
        if (entity.getId() == null) {
            clientTarkingListMapper.insert(entity);
        } else {
            clientTarkingListMapper.updateByPrimaryKey(entity);
        }
    }

    public void delete(Long id) {
        clientTarkingListMapper.deleteByPrimaryKey(id);
    }

    public ClientTarkingList get(Long id) {
        return clientTarkingListMapper.selectByPrimaryKey(id);
    }

    public List<ClientTarkingList> listAll() {
        return clientTarkingListMapper.selectAll();
    }

    @Override
    public PageResult query(ClientTarkingListQuery qo) {
        int count = clientTarkingListMapper.queryCount(qo);
        if (count == 0) {
            return new PageResult(0, Collections.emptyList());
        }
        List<ClientTarkingList> clientTarkingLists = clientTarkingListMapper.queryList(qo);
        PageResult pageResult = new PageResult(count, clientTarkingLists);
        return pageResult;
    }




}
